package com.fqgj.sentry.exception;

import com.fqgj.common.api.enums.ErrorCodeEnum;
import org.springframework.http.HttpStatus;

/**
 * https://github.com/bolasblack/http-api-guide
 * <p>
 * Error Description(Chinese)	Error Description(English)
 * 0	成功	Success
 * 1	未知错误	Unknown error
 * 2	服务暂不可用	Service temporarily unavailable
 * 3	未知的方法	Unsupported openapi method
 * 4	接口调用次数已达到设定的上限	Open api request limit reached
 * 5	请求来自未经授权的IP地址	Unauthorized client IP address:%s
 * 6	无权限访问该用户数据	No permission to access data
 * 7	来自该refer的请求无访问权限	No permission to access data for this referer
 * 100	请求参数无效	Invalid parameter
 * 101	api key无效	Invalid API key
 * 102	session key无效	Session key invalid or no longer valid
 * 103	call_id参数无效	Invalid/Used call_id parameter
 * 104	无效签名	Incorrect signature
 * 105	请求参数过多	Too many parameters
 * 106	未知的签名方法	Unsupported signature method
 * 107	timestamp参数无效	Invalid/Used timestamp parameter
 * 108	无效的user id	Invalid user id
 * 109	无效的用户资料字段名	Invalid user info field
 * 110	无效的access token	Access token invalid or no longer valid
 * 111	access token过期	Access token expired
 * 112	session key过期	Session key expired
 * 114   无效的ip参数 Invalid Ip
 * 210	用户不可见	User not visible
 * 211	获取未授权的字段	Unsupported permission
 * 212	没有权限获取用户的email	No permission to access user email
 * 800	未知的存储操作错误	Unknown data store API error
 * 801	无效的操作方法	Invalid operation
 * 802	数据存储空间已超过设定的上限	Data store allowable quota was exceeded
 * 803	指定的对象不存在	Specified object cannot be found
 * 804	指定的对象已存在	Specified object already exists
 * 805	数据库操作出错，请重试	A database error occurred. Please try again
 * 900	访问的应用不存在	No such biz exists
 * 950	批量操作已开始，请先调用end_batch接口结束前一个批量操作	begin_batch already called, please make sure to call end_batch first
 * 951	结束批量操作的接口调用不应该在start_batch接口之前被调用	end_batch called before start_batch
 * 952	每个批量调用不能包含多于20个接口调用	Each batch API can not contain more than 20 items
 * 953	该接口不适合在批量调用操作中被使用	Method is not allowed in batch mode
 */

/**
 * HTTP状态码	Error_code	Error_msg	备注
 * 500	30600	Internal Server Error	服务器内部错误。
 * 405	30601	Method Not Allowed	不允许的操作（指定了错误的HTTP方法或API）。
 * 400	30602	Request Params Not Valid	请求参数非法。
 * 403	30603	Authentication Failed	权限校验错误 。
 * 402	30604	Quota Use Up Payment Required	无quota。
 * 404	30605	Data Required Not Found	请求数据不存在。
 * 408	30606	Request Time Expires Timeout	请求已超时。
 * 408	30607	Channel Token Timeout	channel_token已经过期。
 * 404	30608	Bind Relation Not Found	绑定关系不存在。
 * 404	30609	Bind Number Too Many	绑定数过多。
 * 409	30610	Duplicate Operation	重复操作。
 * 404	30611	Group Not Found	组不存在。
 */
public enum ErrorCodeEnums implements ErrorCodeEnum {
    //===============sign  权限====================
    sign_error(900000, "sign校验异常", HttpStatus.INTERNAL_SERVER_ERROR),
    permission_error(900000, "没有访问权限", HttpStatus.INTERNAL_SERVER_ERROR),

    //=======================系统错误===================
    server_error(900002, "服务器内部错误", HttpStatus.INTERNAL_SERVER_ERROR),
    motan_service_error(900003, "motan服务异常", HttpStatus.INTERNAL_SERVER_ERROR),
    request_service_error(900004, "暂不支持的请求格式", HttpStatus.INTERNAL_SERVER_ERROR),
    json_transform_error(900005, "json转换异常", HttpStatus.INTERNAL_SERVER_ERROR),

    merchant_code_isnull_error(900005, "商户code不能为空", HttpStatus.INTERNAL_SERVER_ERROR),
    app_code_isnull_error(900005, "应用code不能为空", HttpStatus.INTERNAL_SERVER_ERROR),
    event_code_isnull_error(900005, "事件code不能为空", HttpStatus.INTERNAL_SERVER_ERROR),
    flowno_code_isnull_error(900005, "调用流水号不能为空", HttpStatus.INTERNAL_SERVER_ERROR),
    column_code_isnull_error(900005, "字段不能为空", HttpStatus.INTERNAL_SERVER_ERROR),


    rule_not_exist_error(900005, "暂无可执行规则", HttpStatus.INTERNAL_SERVER_ERROR),
    merchant_not_exists_error(900005, "该商户不存在,请联系管理员", HttpStatus.INTERNAL_SERVER_ERROR),
    application_not_exists_error(900005, "该应用不存在,请联系管理员", HttpStatus.INTERNAL_SERVER_ERROR),
    event_not_exists_error(900005, "该事件不存在,请联系管理员", HttpStatus.INTERNAL_SERVER_ERROR),
    policy_set_not_exist_error(900005, "策略集不存在,请先创建策略集", HttpStatus.INTERNAL_SERVER_ERROR),
    policy_not_exist_error(900005, "执行者暂时不存在策略", HttpStatus.INTERNAL_SERVER_ERROR),
    executor_not_exist_error(900005, "暂时不存在执行者", HttpStatus.INTERNAL_SERVER_ERROR),

    rule_column_not_exist_error(900005, "某些规则字段不存在，请检查", HttpStatus.INTERNAL_SERVER_ERROR),

    column_not_exist_error(900005, "参数字段不能为空", HttpStatus.INTERNAL_SERVER_ERROR),

    hbase_save_error(900005, "hbase存储异常", HttpStatus.INTERNAL_SERVER_ERROR),
    es_save_error(900005, "es存储异常", HttpStatus.INTERNAL_SERVER_ERROR);
    private Integer code;
    private String msg;
    private HttpStatus httpStatus;


    ErrorCodeEnums(Integer code, String msg, HttpStatus httpStatus) {
        this.code = code;
        this.msg = msg;
        this.httpStatus = httpStatus;
    }

    public ErrorCodeEnums setCode(Integer code) {
        this.code = code;
        return this;
    }

    public ErrorCodeEnums setMsg(String msg) {
        this.msg = msg;
        return this;
    }

    public ErrorCodeEnums setHttpStatus(HttpStatus httpStatus) {
        this.httpStatus = httpStatus;
        return this;
    }

    public Integer getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    public HttpStatus getHttpStatus() {
        return httpStatus;
    }
}
